package com.xinghou.platform.entity.req;

import com.xinghou.platform.model.main.Subject;
import org.springframework.util.StringUtils;

/**
 * Created by qingshengzheng on 16/6/23.
 */
public class SubjectReq extends BaseReq {
    //话题id
    public String id;

    public String fromno;

    //页号
    public String pageno;

    public String searchkey;

    public String searchvalue;

    public String pagesize;

    public String pubtime;
    public String joinnum;

    public String getThumurl() {
        return thumurl;
    }

    public void setThumurl(String thumurl) {
        this.thumurl = thumurl;
    }

    public String getPubtime() {
        return pubtime;
    }

    public SubjectReq setPubtime(String pubtime) {
        this.pubtime = pubtime;
        return this;
    }

    public String getOperator() {
        return operator;
    }

    public SubjectReq setOperator(String operator) {
        this.operator = operator;
        return this;
    }

    public String getJoinnum() {
        return joinnum;
    }

    public SubjectReq setJoinnum(String joinnum) {
        this.joinnum = joinnum;
        return this;
    }

    //话题描述
    public String title;
    //话题url
    public String url;
    //话题封面url
    public String thumurl;
    //创建时间
    public String createtime;
    //发布uid
    public String userid;

    public String operator;

   //话题请求转换成话题对象
    public Subject toSubject()
    {
        Subject subject=new Subject();
        if(!StringUtils.isEmpty(id))
        subject.id=Long.parseLong(id);
        subject.title=title;
        subject.operator=operator;
        subject.thumurl=thumurl;
        if(!StringUtils.isEmpty(createtime))
        subject.createtime=Long.parseLong(createtime);
        subject.url=url;
        if(!StringUtils.isEmpty(userid))
        subject.uid=Integer.parseInt(userid);
        if(!StringUtils.isEmpty(pubtime))
            subject.pubtime=Long.parseLong(pubtime);

        return subject;
    }
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }


    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public String getCreatetime() {
        return createtime;
    }

    public SubjectReq setCreatetime(String createtime) {
        this.createtime = createtime;
        return this;
    }

    public String getFromno() {
        if(!StringUtils.isEmpty(fromno)){
            return fromno;
        }else{
            return String.valueOf((Integer.parseInt(pageno)-1)*10);
        }
    }

    public SubjectReq setFromno(String fromno) {
        this.fromno = fromno;
        return this;
    }

    public String getPageno() {
        return pageno;
    }

    public SubjectReq setPageno(String pageno) {
        this.pageno = pageno;
        return this;
    }

    public String getPagesize() {
        return pagesize;
    }

    public SubjectReq setPagesize(String pagesize) {
        this.pagesize = pagesize;
        return this;
    }

    public String getSearchkey() {
        return searchkey;
    }

    public SubjectReq setSearchkey(String searchkey) {
        this.searchkey = searchkey;
        return this;
    }

    public String getSearchvalue() {
        return searchvalue;
    }

    public SubjectReq setSearchvalue(String searchvalue) {
        this.searchvalue = searchvalue;
        return this;
    }
}
